﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PPT = Microsoft.Office.Interop.PowerPoint;
using Office = Microsoft.Office.Core;
using System.ComponentModel;
using System.DirectoryServices.ActiveDirectory;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;

namespace An_Im
{
    class BehaviorInformation : TimeInformation
    {
        public PPT.MsoAnimType AnimType { get; set; }

    }

    class SetBehaviorInformation : BehaviorInformation
    {
        public PPT.MsoAnimProperty? Property { get; set; }
        public dynamic Value { get; set; }

        public SetBehaviorInformation()
        {
            AnimType = PPT.MsoAnimType.msoAnimTypeSet;

        }

    }


    public class KeyPointInformation : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        public string Note { get; set; }


        #region prop

        /// <summary>
        /// 时间。
        /// </summary>
        public double Time { get { return _time; } set { _time = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Time")); } }
        private double _time = 0;

        /// <summary>
        /// 变量表达式。
        /// </summary>
        public dynamic Value { get; set; } = string.Empty;

        /// <summary>
        /// 表达式。
        /// </summary>
        public string Formula { get; set; } = "$";

        #endregion


        #region ctor

        public KeyPointInformation() { }

        public KeyPointInformation(double time, object value, string formula)
        {
            if (formula is null) formula = "$";
            Time = time; Value = value; Formula = formula;
        }

        public KeyPointInformation(KeyPointInformation keyPointInformation)
        {
            Time = keyPointInformation.Time; Value = keyPointInformation.Value; Formula = keyPointInformation.Formula;
        }

        public KeyPointInformation(double time)
        {
            Time = time; Value = "0"; Formula = "$";
        }

        #endregion


        #region access method
        public string GetValue()
        {
            if (Value is string) return Value as string;
            if (Value is bool) return (bool)Value == true ? "1" : "0";
            if (Value is int) return ((int)Value).ToString();
            return string.Empty;
        }


        public void SetValue(string value)
        {
            try
            {
                Value = value;
            }
            catch (Exception)
            {
                Value = value.ToInt();
            }
        }

        #endregion

        #region static
        static KeyPointInformation()
        {
            DefaultFirst = new KeyPointInformation(0, "0", "$");
            DefaultLast = new KeyPointInformation(1, "1", "$");
        }


        /// <summary>
        /// 默认的结束点信息。
        /// </summary>
        public static KeyPointInformation DefaultLast { get; private set; }


        /// <summary>
        /// 默认的起始点信息。
        /// </summary>
        public static KeyPointInformation DefaultFirst { get; private set; }

        #endregion




    }

    class PropertyBehaviorInformation : BehaviorInformation
    {
        public PPT.MsoAnimProperty? Property { get; set; }
        //public dynamic Value { get; set; }
        public dynamic From { get; set; }
        public dynamic To { get; set; }
        public List<KeyPointInformation> KeyPoints { get; set; }

        public PropertyBehaviorInformation()
        {
            AnimType = PPT.MsoAnimType.msoAnimTypeProperty;

        }

    }


    class ColorBehaviorInformation : BehaviorInformation
    {
        public int? From { get; set; }
        public int? To { get; set; }
        public int? By { get; set; }
        public ColorBehaviorInformation()
        {
            AnimType = PPT.MsoAnimType.msoAnimTypeColor;
        }

    }

    class ScaleBehaviorInformation : BehaviorInformation
    {
        public float? FromX { get; set; }
        public float? ToX { get; set; }
        public float? ByX { get; set; }
        public float? FromY { get; set; }
        public float? ToY { get; set; }
        public float? ByY { get; set; }

        public ScaleBehaviorInformation()
        {
            AnimType = PPT.MsoAnimType.msoAnimTypeScale;
        }

    }

    class RotationBehaviorInformation : BehaviorInformation
    {
        public float? From { get; set; }
        public float? To { get; set; }
        public float? By { get; set; }

        public RotationBehaviorInformation()
        {
            AnimType = PPT.MsoAnimType.msoAnimTypeRotation;
        }

    }

    class FilterBehaviorInformation : BehaviorInformation
    {
        public PPT.MsoAnimFilterEffectType? MainFilter { get; set; }
        public PPT.MsoAnimFilterEffectSubtype? SubFilter { get; set; }
        public Office.MsoTriState? Reveal { get; set; }

        public FilterBehaviorInformation()
        {
            AnimType = PPT.MsoAnimType.msoAnimTypeFilter;
        }

    }


    class MotionBehaviorInformation : BehaviorInformation
    {
        public PPT.MsoAnimProperty? Property { get; set; }
        public float? FromX { get; set; }
        public float? ToX { get; set; }
        public float? ByX { get; set; }
        public float? FromY { get; set; }
        public float? ToY { get; set; }
        public float? ByY { get; set; }
        public string Path { get; set; }

        public MotionBehaviorInformation()
        {
            AnimType = PPT.MsoAnimType.msoAnimTypeMotion;
        }

    }

}
